package com.ruoyi.web.controller.business;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.vo.business.PageScriptRecordInfoVo;
import com.ruoyi.system.domain.vo.business.ScriptRecordInfoVo;
import com.ruoyi.system.dto.business.PageScriptRecordDto;
import com.ruoyi.system.dto.business.ReceiptDto;
import com.ruoyi.system.service.IReceiptFileService;
import com.ruoyi.system.service.impl.ScriptRecordInfoServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 剧本备案信息管理 前端控制器
 * </p>
 *
 * @author yanfu
 * @since 2024-03-23
 */
@RestController
@RequestMapping("/script/record/info")
@RequiredArgsConstructor
@Api(tags = {"剧本备案信息管理"})
public class ScriptRecordInfoController {

    private final ScriptRecordInfoServiceImpl scriptRecordInfoService;

    private final IReceiptFileService receiptFileService;

    @PostMapping("/page")
    @ApiOperation(value = "剧本备案信息管理-列表")
    public AjaxResult<Page<PageScriptRecordInfoVo>> getScriptRecordInfo(@RequestBody PageScriptRecordDto dto) {
        Page<PageScriptRecordInfoVo> voPage = scriptRecordInfoService.getScriptRecordInfo(dto);
        return AjaxResult.success(voPage);
    }


//    @PostMapping("/pageList")
//    @ApiOperation(value = "剧本备案信息管理-列表")
//    public AjaxResult<Page<PageScriptRecordInfoVo>> pageList(@RequestBody PageScriptRecordDto dto) {
//        Page<PageScriptRecordInfoVo> voPage = scriptRecordInfoService.getScriptRecordInfo(dto);
//        return AjaxResult.success(voPage);
//    }

    @GetMapping("/detail")
    @ApiOperation(value = "剧本备案信息管理-详情")
    public AjaxResult<ScriptRecordInfoVo> getScriptRecordInfodetail(@RequestParam(value = "id", required = true) Long id) {
        ScriptRecordInfoVo vo = scriptRecordInfoService.getScriptRecordInfodetail(id);
        return AjaxResult.success(vo);
    }

    @PostMapping("/receipt")
    @ApiOperation(value = "剧本备案信息管理-回执单保存")
    public AjaxResult<String> saveReceipt(@RequestBody List<ReceiptDto> dtos) {
        scriptRecordInfoService.saveReceipt(dtos);
        return AjaxResult.success();
    }

    @DeleteMapping("/receipt/del")
    @ApiOperation(value = "剧本备案信息管理-回执单删除")
    public AjaxResult<String> delReceipt(@RequestParam(value = "id", required = true) Long id) {
        receiptFileService.removeById(id);
        return AjaxResult.success();
    }
}

